<?php
declare(strict_types=1);

namespace App\AdminApi\Modular\System\Controller;

use App\AdminApi\BasicsController;
use App\Common\Extend\Guard\Auth;
use Core\HyperfUnit\Response;
use Hyperf\HttpServer\Annotation\{Controller, PostMapping};
use Psr\Http\Message\ResponseInterface;

#[
    Auth(guard: self::GUARD, label: ['系统管理', '优化维护'], app: self::APP),
    Controller(prefix: "/admin-api/system-maintain", server: self::SERVER)
]
class MaintainController extends BasicsController
{
    #[
        PostMapping('clear-cache'),
        Auth(label: ['刷新缓存'], sign: 'system.maintain.clear-cache', describe: "刷新系统缓存")
    ]
    public function clearCache(): ResponseInterface
    {
        cache()->clear();
        return Response::Api()->success('系统缓存已刷新');
    }
}